<?php
class Anggota_model extends CI_Model {

		function __construct(){
		
			parent::__construct();
			
		
		}

		function getAnggota($query=False,$id_member=FALSE,$cari=FALSE,$limit=FALSE,$offset=FALSE){
			if ($query == 'list'){
				$this->db->order_by('id_member','desc');
				return $this->db->get('tb_member')->result_array();
			
			}
			
			elseif ($query == 'by_id') {
				$this->db->where('id_member',$id_member);
				$this->db->order_by('id_member','desc');
				return $this->db->get('tb_member')->row();
			
			}
			elseif ($query == 'cari') {
			$this->db->like('nim',$cari);
			return $this->db->get('tb_member')->result_array();
			
			}
		
		
		}

		function addAnggota($data){
			$this->db->insert('tb_member',$data);
		
		}
		
		function editAnggota($id,$data){
			$this->db->where('id_member',$id);
			$this->db->update('tb_member',$data);
				
		}
		
		function deleteAnggota($id){
			$this->db->where('id_member',$id);
			$this->db->delete('tb_member');
					
		}
		
		
		
}



?>